exports.__esModule = true;

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

exports.default = class extends think.BaseController {
  __before() {}
  /**
   *@description 更新/编辑地片
   */
  doAddOrUpdateAction() {
    var _this = this;

    return _asyncToGenerator(function* () {
      let aj = think.ajaxJson();
      const data = _this.post("id,ZoneName,ZoneID,Alias,OldName,Boundary,SubDisName,SubDisCode,CommuName,CommuCode,Baidu_lng,Baidu_lat,DataSource,ORDate,CHDate,Note");
      const ZoneService = _this.service("geo/ZoneService");
      const res = yield ZoneService.doAddOrUpdateZone(data);
      if (!res.error) {
        aj.result = res;
      } else {
        aj.success = false;
        aj.msg = "更新失败";
      }
      return _this.json(aj);
    })();
  }

  /**
   * 获取区片数据 带分页
   *
   * @returns
   */
  doGetZoneListForPageAction() {
    var _this2 = this;

    return _asyncToGenerator(function* () {
      let aj = think.ajaxJson();
      const data = _this2.get("page,pageSize,ZoneName");
      console.log(data);
      const ZoneService = _this2.service("geo/ZoneService");
      const Res = yield ZoneService.getZoneListPage(data);
      if (!Res.error) {
        aj.result = Res;
      } else {
        aj.success = false;
        aj.msg = "获取失败";
      }
      return _this2.json(aj);
    })();
  }

  /**
   * 通过id查询区片数据
   */
  delZoneByIdAction() {
    var _this3 = this;

    return _asyncToGenerator(function* () {
      let aj = think.ajaxJson();
      const data = { id: _this3.post("id") };
      console.log(data);
      const ZoneService = _this3.service("geo/ZoneService");
      const Res = yield ZoneService.delZoneById(data);
      if (!Res.error) {
        aj.result = Res;
      } else {
        aj.success = false;
        aj.msg = "获取失败";
      }
      return _this3.json(aj);
    })();
  }
  /**
   * 通过SubDisCode和CommuCode查询区片数据
   */
  getZoneBySubComCodeAction() {
    var _this4 = this;

    return _asyncToGenerator(function* () {
      let aj = think.ajaxJson();
      const data = _this4.get("SubDisCode,CommuCode");
      console.log(data);
      const ZoneService = _this4.service("geo/ZoneService");
      const Res = yield ZoneService.getZoneBySubComCode(data);
      if (!Res.error) {
        aj.result = Res;
      } else {
        aj.success = false;
        aj.msg = "获取失败";
      }
      return _this4.json(aj);
    })();
  }

  /**
   * 获取所有区片数据
   */
  getZoneAllAction() {
    var _this5 = this;

    return _asyncToGenerator(function* () {
      let aj = think.ajaxJson();
      const ZoneService = _this5.service("geo/ZoneService");
      const Res = yield ZoneService.getZoneAll();
      if (!Res.error) {
        aj.result = Res;
      } else {
        aj.success = false;
        aj.msg = "获取失败";
      }
      return _this5.json(aj);
    })();
  }
  __call() {}
};